import {createRouter,createWebHistory,RouteRecordRaw} from  'vue-router'
const routes:RouteRecordRaw[] = [
    {
        path:'/',
        name:'layout',
        component:()=>import('../view/Layout.vue'),
        redirect:'/home',
        meta:{
            required:true
        },
        children:[
            {
                path:'/home',
                component:()=>import('../view/Home.vue')
            }
        ]
    },
    {
        path:'/login',
        component:()=>import('../view/Login.vue')
    },
    {
        path:'/:pathMatch(.*)*',
        // 不加的话要required:true,跳到notfound 页，加的话被在permission.js中被拦截，跳到login 页
        meta:{required:true},
        name:'notfound',
        component:()=>import('../view/NotFound.vue')
    }
  
]
// export const staticRouter = [
//     {
//         path:'/',
//         name:'layout',
//         component:()=>import('../view/Layout.vue'),
//         redirect:'/home',
//         meta:{
//             required:true
//         },
//         children:[
//             {
//                 path:'/home',
//                 component:()=>import('../view/Home.vue')
//             }
//         ]
//     },
//     {
//         path:'/:pathMatch(.*)*',
//         name:'notfound',
//         component:()=>import('../view/NotFound.vue')
//     }
// ]
export const router = createRouter({
    history:createWebHistory(import.meta.env.BASE_URL),
    routes:routes
})


// 注意  嵌套路由中的子路由 path中加 '/'和不加的区别     
//  加的话地址栏可以直接访问  如'http:....:5000/home' 而不需要加上父路由  可以router.getRoutes()查看